unit RoomExit;

interface

uses
  Database, AM,
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, Mask, Menus, ColorGrd, ExtCtrls;

type
  TFormRoomExit = class(TForm)
    Label7: TLabel;
    Label11: TLabel;
    Label13: TLabel;
    EditExit: TEdit;
    EditPreAction: TEdit;
    EditPostAction: TEdit;
    BtnOK: TBitBtn;
    BtnCancel: TBitBtn;
    BtnAM: TBitBtn;
    BtnAM2: TBitBtn;
    MainMenu1: TMainMenu;
    Invisible1: TMenuItem;
    CtrlA1: TMenuItem;
    Label1: TLabel;
    Bevel2: TBevel;
    ColorGrid: TColorGrid;
    procedure BtnCancelClick(Sender: TObject);
    procedure BtnOKClick(Sender: TObject);
    procedure BtnAMClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    linked: boolean;
  end;

var
  FormRoomExit: TFormRoomExit;

implementation

{$R *.DFM}

procedure TFormRoomExit.FormCreate(Sender: TObject);
begin
  linked:=false;
end;

procedure TFormRoomExit.BtnCancelClick(Sender: TObject);
begin
  close;
end;

procedure TFormRoomExit.BtnOKClick(Sender: TObject);
begin
  if EditExit.text = '' then begin
    messagedlg('The exit cannot be blank',mtinformation,[mbok],0);
    EditExit.setfocus;
    exit;
  end;
  linked:=true;
  close;
end;

procedure TFormRoomExit.BtnAMClick(Sender: TObject);
var
  form: TFormAM;
  am: string;
  ed: TEdit;
begin
  if (TComponent(sender).tag = 999) then begin
    if ActiveControl = EditPreAction then ed:=EditPreAction
    else if ActiveControl = EditPostAction then ed:=EditPostAction
    else exit;
  end
  else begin
    case TComponent(sender).tag of
      1: ed:=EditPreAction;
      2: ed:=EditPostAction;
      else raise Exception.CreateFmt('TFormRoomExit.BtnAMClick: Invalid sender tag: %d', [TComponent(sender).tag]);
    end;
  end;
  form:=TFormAM.create(self);
  form.setup;
  form.showmodal;
  am:=form.am;
  form.free;
  if am = '' then exit;
  ed.text:=am;
  ed.setfocus;
end;

end.
